package com.windfone.common;

public class PageUtil {
	private int currentPage;
	private int nextPage;
	private int prevPage;
	private int totalRecords;
	private int pageSize;
	private int totalPage;
	public int getTotalPage() {
		return totalPage;
	}
	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}
	public int getPrevPage() {
		return prevPage;
	}
	public void setPrevPage(int prevPage) {
		this.prevPage = prevPage;
	}
	public int getCurrentPage() {
		return currentPage;
	}
	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}
	public int getNextPage() {
		return nextPage;
	}
	public void setNextPage(int nextPage) {
		this.nextPage = nextPage;
	}
	public int getTotalRecords() {
		return totalRecords;
	}
	public void setTotalRecords(int totalRecords) {
		this.totalRecords = totalRecords;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	
	public void dealPage(){
		totalPage = totalRecords/pageSize;
		int leftRecords = totalRecords%pageSize;
		if ( leftRecords != 0  )
			totalPage = totalPage + 1;
		
		if ( currentPage <= 0  ){
			currentPage = 1; 
			nextPage = 1;
			prevPage = 1;
		} else { 
			if ( currentPage>=  totalPage)
				currentPage = totalPage;
			
			if ( (currentPage-1)>0)
				prevPage = currentPage-1;
			else 
				prevPage = currentPage;
			 
			if ( currentPage+1>= totalPage )
				nextPage =  totalPage ;
			else {
				nextPage = currentPage + 1;
			}
		}
	}
	
	
	public static void main(String args[]){
		int totals = 99;
		int size = 5; 
		int current = 3;
		int nextpage = 3;
		System.out.println( totals%size);
		System.out.println( totals/size);
	}
}
